<!DOCTYPE html>
<html>
<?php //var_dump($output['address_list']);exit;?>
<head>
    <meta charset="utf-8">
    <title>金贵银业</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <!--标准mui.css-->
    <link rel="stylesheet" href="<?php echo MOBILE_RESOURCE_SITE_URL; ?>/css/mui.min.css">
    <!--App自定义的css-->
    <link rel="stylesheet" type="text/css" href="<?php echo MOBILE_RESOURCE_SITE_URL; ?>/css/app.css" />
    <!--App自定义的css-->
    <link rel="stylesheet" type="text/css" href="<?php echo MOBILE_RESOURCE_SITE_URL; ?>/css/zhaojinyin_index.css" />
    <link href="<?php echo MOBILE_RESOURCE_SITE_URL; ?>/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <script src="<?php echo MOBILE_RESOURCE_SITE_URL; ?>/js/mui.min.js"></script>
    <script src="<?php echo MOBILE_RESOURCE_SITE_URL; ?>/js/jquery-1.8.0.min.js"></script>
    <style>
        .mui-control-content {
            background-color: white;
            min-height: 215px;
        }

        .mui-control-content .mui-loading {
            margin-top: 50px;
        }

        a.mui-active {
            border-bottom: 2px solid #BB9E77 !important;
            color: #BB9E77 !important;
        }
        .mui-popup{position: fixed;}
    </style>
    <script type="text/javascript" charset="utf-8">
        mui.init({
            swipeBack: true //启用右滑关闭功能
        });
        (function($, doc) {
            $.plusReady(function() {
                //找相似
                doc.getElementById("add_address").addEventListener('tap', function() {
                    $.openWindow({
                        url: 'huiyuanzhongxin_add_address.html'
                    });
                }, false);
                //找相似
                doc.getElementById("update_address").addEventListener('tap', function() {
                    $.openWindow({
                        url: 'huiyuanzhongxin_update_address.html'
                    });
                }, false);
            });
        }(mui, document));


    </script>

</head>

<body style="padding-bottom: 150px;">

<div class="mui-bar" style="height: 45px;top: 0;">
    <a class="mui-icon mui-icon-left-nav"  href="/mobile/index.php?act=member_index&op=member_index"></a>
    <!--
        时间：2016-03-24
        描述：右边按钮
    -->
    <a id="add_address" class="mui-icon mui-pull-right font_sz_16" style="color: #666666 !important;line-height: 28px;" href="/mobile/index.php?act=member_index&op=member_address_add">添加</a>
    <h1 class="mui-title">收货地址</h1>
</div>

<div class="mui-content" style="margin-top: 46px;">
<?php foreach($output['address_list'] as $a){?>

    <div style="background:#FFFFFF;padding: 3px 0px; margin: 15px  auto;">
        <div style=" padding: 15px 15px 0px 15px; background:#FFFFFF;">
            <div style="line-height: 30px;">
                <label><img src="<?php echo MOBILE_RESOURCE_SITE_URL; ?>/images/wo103.png" style="vertical-align: middle; width: 20px;"></label>
                <label><?php echo $a['true_name'];?></label>
                <label style="margin-left: 20px;"><img src="<?php echo MOBILE_RESOURCE_SITE_URL; ?>/images/phone127.png" style="vertical-align: middle; width: 16px;"></label>
                <label><?php echo $a['mob_phone'];?></label>
            </div>
            <div class="c666666" style="margin-top: 5px;">
                <p style="margin-bottom: -10px; color: #666666;">收货地址：<?php echo $a['area_info'].' '.$a['address'];?></p>
            </div>

        </div>

        <div class="c666666" style="margin-top: 25px; border-top: 1px solid #EEEEEE; padding:0 12px;">
            <div class="mui-input-row mui-checkbox mui-left" style="padding: 0 !important; width: 50%; float: left;">
                <?php if($a['is_default']==1)   {?>
                    <button style="padding-left: 30px;line-height: 26px; color: grey; width: 100%;border: none;">默认地址</button>
                <?php  }else{ ?>
                <button class="d_address" data-id="<?php echo $a['address_id'];?>" style="padding-left: 30px;line-height: 26px;width: 100%;border: none;">设为默认</button>
<!--                <input style="margin-left: -22px;margin-top: 6px;" name="checkbox" value="Item 2" type="checkbox">-->
                <?php } ?>
            </div>
            <div style="float: right; width: 50%; text-align: right; line-height: 50px; height: 28px;">
                <label id="update_address"><img src="<?php echo MOBILE_RESOURCE_SITE_URL; ?>/images/bianji049.png" style="vertical-align: middle;margin: 5px;" />编辑</label>
                <label class ="del_btn" style="margin-left: 10px;" data-id="<?php echo $a['address_id'];?>" data-action="del">删除 </label>
            </div>
        </div>&nbsp;
    </div>

<?php }?>


</div>
<script type="text/javascript" charset="utf-8">
    //mui初始化
    mui.init({
        swipeBack: true //启用右滑关闭功能
    });
    //document.getElementById("confirmBtn").addEventListener('tap', function() {

    //});

    $(document).ready(function(){
        btn_load()
    })
    function btn_load(){
        
        $(".d_address").bind('click',function(){
            $(".d_address").unbind();
            $(".d_address").css("color",'#000')
            var btn = $(this)
            var id = $(this).attr("data-id");
            $.ajax({
                type: 'POST',
                data: {default:id} ,
                url: 'index.php?act=member_index&op=member_address3',//url
                success: function (msg) {
                    console.log(msg)
                    if(msg === "1"){
                        alert("设置成功");
                        btn.css("color","grey");
                    }else{
                        alert("miss");
                    }
                    btn_load()
                }
            })
        })

        $(".del_btn").each(function(){
            $(this).unbind();
            $(this).bind("click",function(){

                var id = $(this).attr("data-id");
                var action = $(this).attr("data-action");

                mui.confirm('你是否确定删除该收货地址，确认？', '提示',['否', '是'], function(e) {
                    if (e.index == 1) {
                        
                        $.ajax({
                            type: 'POST',
                            url: 'index.php?act=member_index&op=member_address2',//url
                            data: {action:action,id:id} ,
                            dataType: 'json',
                            success: function(msg){
                                console.log("传输成功！")
                                console.log(msg.feedback)
                                window.open("index.php?act=member_index&op=member_address","_self")
                                btn_load()
                            },
                            error:function(msg){
                                console.log(msg)
                                btn_load()
                            }
                        });
                        $(".mui-popup-backdrop,.mui-popup").remove()
                    } else {
                            btn_load()
                        $(".mui-popup-backdrop,.mui-popup").remove()
                    }

                })

            })
        })
    }

</script>
</body>

</html>